

let fs = require('fs');
let school = {};
let event ={
    arr:[],
    on:function(fn){
        this.arr.push(fn)
    },
    emit:function(){
        this.arr.forEach(fn=>fn())
    }
}
event.on(function(){
    if(Object.keys(school).length === 2){
        console.log(school);
    }
})
event.on(function(){
    if(school.name){
        console.log(school);
    }
})
fs.readFile('./name.txt','utf8',function(err,data){
    school.name = data;
    event.emit() 
})
fs.readFile('./age.txt','utf8',function(err,data){
    school.age = data;
    event.emit()
})
